class Solution {
public:
    vector<int> distributeCandies(int ans, int num_people) {
        vector<int> nums(num_people,0);
        int i=1;
        int j=0;
        while(ans>0)
        {
            if(ans>i)
            {
                nums[j%num_people]+=i;
            }
            else
            {
                i=ans;
                nums[j%num_people]+=i;
            }
            ans-=i;
            i+=1;
            j+=1;
        }
        return nums;
    }
};